import {renderNotFound, isInIcestark} from "@ice/stark-app";
import BasicLayout from "@/layouts/BasicLayout";
import HomeLayout from "@/layouts/HomeLayout";
import {NotFound} from "@/components";
import {childConfig} from "@/config";
import EnumRouter from "@/config/EnumRouter";
import {IProps, RouteType} from "@/interface";

interface RouterConfig {
  title?: string,
  path?: string;
  component?: ({children, location, history}: IProps) => JSX.Element;
  children?: any[];
  routeWrappers?: any,
  redirect?: string
}

const routerConfig: (RouterConfig | RouteType)[] = [


  ...childConfig.basicRoutes,

  // *****   框架下的可管理路由   *****  //
  {
    path: "/",
    component: isInIcestark() ? BasicLayout : HomeLayout,
    children: [
      ...childConfig.mainRoutes,
      {
        path: '/',
        // 重定向
        redirect: EnumRouter.groups_work
      },
      {
        // 微应用独立运行 404 路由渲染 NotFound 组件
        component: isInIcestark() ? () => renderNotFound() : NotFound,
      },
    ],
  },
  {
    // 微应用独立运行 404 路由渲染 NotFound 组件
    component: isInIcestark() ? () => renderNotFound() : NotFound,
  },
];

export default routerConfig;
